package com.link2room.blaster.controller.manager;

import com.link2room.blaster.dto.innerUse.InmailBaseDto;
import com.link2room.blaster.facade.IInmailReceiverFacadeService;
import com.link2room.common.dto.result.base.BaseResultDto;
import com.link2room.blaster.dto.param.inMail.InmailReceiverCreateParamDto;
import com.link2room.blaster.dto.param.inMail.InmailReceiverListParamDto;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * Created by LN on 2017/6/29.11:58
 */
@Api(tags = "站内消息接收用户设置相关")
@RestController
@RequestMapping("/manager/Receivers")
public class InmailReceiverController {

    @Resource
    private IInmailReceiverFacadeService inmailReceiverFacadeService;

    @ApiOperation(value = "增加消息接收人", response = InmailBaseDto.class)
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "paramDto", paramType = "body", required = true),
    })
    @RequestMapping(method = RequestMethod.POST)
    public BaseResultDto add(@RequestBody InmailReceiverCreateParamDto paramDto) throws Exception {
        inmailReceiverFacadeService.update(paramDto);
        BaseResultDto l2rRs = new BaseResultDto();
        l2rRs.setResultCode(0);
        return l2rRs;
    }

    @RequestMapping(method = RequestMethod.GET)
    private BaseResultDto list(
            @RequestParam("lhotelCode") String lhotelCode,
            @RequestParam("inmailType") String inmailType
    ) throws Exception {

        InmailReceiverListParamDto paramDto = new InmailReceiverListParamDto();
        paramDto.setLhotelCode(lhotelCode);
        paramDto.setInmailType(inmailType);
        BaseResultDto l2rRs = new BaseResultDto();
        l2rRs.setResultInfo(inmailReceiverFacadeService.inmailReceiverList(paramDto));
        l2rRs.setResultCode(0);
        return l2rRs;
    }

}
